package cn.anecansaitin.firecrafting.common.capability.item;

import net.minecraft.core.NonNullList;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;

import java.util.function.BiConsumer;

//当库存变动时会执行操作的物品能力
public class SensitiveItemStackHandler extends ItemStackHandler {
    private final BiConsumer<NonNullList<ItemStack>, Integer> action;

    public SensitiveItemStackHandler(int size, BiConsumer<NonNullList<ItemStack>, Integer> action) {
        super(size);
        this.action = action;
    }

    @Override
    protected void onContentsChanged(int slot) {
        action.accept(stacks, slot);
    }
}
